package org.nfIt.validation;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.nfIt.anno.State;


/**
 * ClossName:StateValidation
 * Pakage:org.nfIt.validation
 * Description
 *
 * ConstraintValidator<给哪个注解提供校验规则,校验的数据类型>
 *
 *
 * @Author L
 * @Create 2024/6/6 8:56
 * @Version 2023.1.3
 */
public class StateValidation implements ConstraintValidator<State, String> {


    /**
     *
     * @param value 要校验的数据
     * @param constraintValidatorContext 指定提供校验规则的类
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {

        if (value == null) {
            return false;
        }

        if (value.equals("已发布")  || value.equals("草稿")){
            return true;
        }

        return false;

    }
}
